<?php if(!defined('HDPHP_PATH'))EXIT;
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."admin`");
$db->exe("CREATE TABLE `".$db_prefix."admin`".$db_prefix." (
  `".$db_prefix."aid`".$db_prefix." smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."username`".$db_prefix." varchar(30) NOT NULL DEFAULT '',
  `".$db_prefix."password`".$db_prefix." char(32) NOT NULL DEFAULT '',
  `".$db_prefix."email`".$db_prefix." varchar(50) NOT NULL DEFAULT '',
  `".$db_prefix."add_time`".$db_prefix." timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`".$db_prefix."aid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."attribute`");
$db->exe("CREATE TABLE `".$db_prefix."attribute`".$db_prefix." (
  `".$db_prefix."attr_id`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."attr_name`".$db_prefix." varchar(20) NOT NULL DEFAULT '' COMMENT '类型属性的名称',
  `".$db_prefix."attr_value`".$db_prefix." varchar(255) NOT NULL DEFAULT '' COMMENT '类型属性的值',
  `".$db_prefix."class`".$db_prefix." tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '类型属性的类别，0表示属性，1表示规格',
  `".$db_prefix."type_id`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '所属类型ID',
  PRIMARY KEY (`".$db_prefix."attr_id`".$db_prefix."),
  KEY `".$db_prefix."taname`".$db_prefix." (`".$db_prefix."attr_name`".$db_prefix."),
  KEY `".$db_prefix."fk_ccshop_type_attr_ccshop_type1_idx`".$db_prefix." (`".$db_prefix."type_id`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=23 DEFAULT CHARSET=utf8 COMMENT='类型属性表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."brand`");
$db->exe("CREATE TABLE `".$db_prefix."brand`".$db_prefix." (
  `".$db_prefix."brand_id`".$db_prefix." smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."brand_name`".$db_prefix." varchar(30) NOT NULL DEFAULT '',
  `".$db_prefix."brand_desc`".$db_prefix." varchar(255) NOT NULL DEFAULT '',
  `".$db_prefix."url`".$db_prefix." varchar(100) NOT NULL DEFAULT '',
  `".$db_prefix."logo`".$db_prefix." varchar(50) NOT NULL DEFAULT '',
  `".$db_prefix."sort_order`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."is_show`".$db_prefix." tinyint(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`".$db_prefix."brand_id`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=12 DEFAULT CHARSET=utf8");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."cart`");
$db->exe("CREATE TABLE `".$db_prefix."cart`".$db_prefix." (
  `".$db_prefix."cart_id`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '购物车id',
  `".$db_prefix."uid`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
  `".$db_prefix."goods_id`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."goods_name`".$db_prefix." varchar(100) NOT NULL DEFAULT '' COMMENT '商品名称',
  `".$db_prefix."goods_img`".$db_prefix." varchar(50) NOT NULL DEFAULT '' COMMENT '商品图片',
  `".$db_prefix."goods_attr`".$db_prefix." varchar(255) NOT NULL DEFAULT '',
  `".$db_prefix."goods_number`".$db_prefix." smallint(5) unsigned NOT NULL DEFAULT '1' COMMENT '库存',
  `".$db_prefix."goods_price`".$db_prefix." decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '本店价',
  `".$db_prefix."market_price`".$db_prefix." decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '市场价',
  `".$db_prefix."subtotal`".$db_prefix." decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '总计',
  PRIMARY KEY (`".$db_prefix."cart_id`".$db_prefix.")
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."category`");
$db->exe("CREATE TABLE `".$db_prefix."category`".$db_prefix." (
  `".$db_prefix."cid`".$db_prefix." smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."cname`".$db_prefix." varchar(30) NOT NULL DEFAULT '',
  `".$db_prefix."pid`".$db_prefix." smallint(5) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."cdesc`".$db_prefix." varchar(255) NOT NULL DEFAULT '',
  `".$db_prefix."csort`".$db_prefix." tinyint(4) NOT NULL DEFAULT '50',
  `".$db_prefix."ico`".$db_prefix." varchar(15) DEFAULT '',
  `".$db_prefix."is_show`".$db_prefix." tinyint(4) NOT NULL DEFAULT '1',
  `".$db_prefix."type_id`".$db_prefix." smallint(6) NOT NULL,
  `".$db_prefix."ctitle`".$db_prefix." varchar(30) NOT NULL,
  PRIMARY KEY (`".$db_prefix."cid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=132 DEFAULT CHARSET=utf8");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."config`");
$db->exe("CREATE TABLE `".$db_prefix."config`".$db_prefix." (
  `".$db_prefix."coid`".$db_prefix." smallint(5) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  `".$db_prefix."name`".$db_prefix." varchar(15) NOT NULL DEFAULT '' COMMENT '配置项名称',
  `".$db_prefix."value`".$db_prefix." varchar(70) NOT NULL DEFAULT '' COMMENT '配置值',
  `".$db_prefix."title`".$db_prefix." varchar(45) NOT NULL DEFAULT '' COMMENT '配置项标题',
  `".$db_prefix."des`".$db_prefix." varchar(255) NOT NULL DEFAULT '' COMMENT '配置项详细描述',
  `".$db_prefix."type_id`".$db_prefix." tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '配置项类型id，相同类型id相同',
  PRIMARY KEY (`".$db_prefix."coid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=25 DEFAULT CHARSET=utf8 COMMENT='站点配置'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."detail`");
$db->exe("CREATE TABLE `".$db_prefix."detail`".$db_prefix." (
  `".$db_prefix."img_id`".$db_prefix." int(11) NOT NULL AUTO_INCREMENT,
  `".$db_prefix."small`".$db_prefix." varchar(255) NOT NULL DEFAULT '' COMMENT '小图图册地址',
  `".$db_prefix."medium`".$db_prefix." varchar(255) NOT NULL DEFAULT '' COMMENT '中图图册地址',
  `".$db_prefix."big`".$db_prefix." varchar(255) NOT NULL DEFAULT '' COMMENT '大图图册地址',
  `".$db_prefix."intro`".$db_prefix." text COMMENT '商品详情',
  `".$db_prefix."service`".$db_prefix." text COMMENT '售后服务',
  `".$db_prefix."gid`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '所属商品ID',
  PRIMARY KEY (`".$db_prefix."img_id`".$db_prefix."),
  KEY `".$db_prefix."fk_ccshop_detail_ccshop_goods1_idx`".$db_prefix." (`".$db_prefix."gid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=142 DEFAULT CHARSET=utf8 COMMENT='商品详细信息表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."flink`");
$db->exe("CREATE TABLE `".$db_prefix."flink`".$db_prefix." (
  `".$db_prefix."fid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '友情链接主键id',
  `".$db_prefix."fname`".$db_prefix." varchar(30) NOT NULL DEFAULT '' COMMENT '友情链接名称',
  `".$db_prefix."msg`".$db_prefix." varchar(150) NOT NULL DEFAULT '' COMMENT '友情链接描述',
  `".$db_prefix."addtime`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间',
  `".$db_prefix."sort`".$db_prefix." smallint(5) unsigned NOT NULL DEFAULT '100' COMMENT '排序',
  `".$db_prefix."logo`".$db_prefix." varchar(80) NOT NULL DEFAULT '' COMMENT '友情链接Logo',
  `".$db_prefix."url`".$db_prefix." varchar(75) NOT NULL DEFAULT '' COMMENT '友情链接地址',
  `".$db_prefix."is_show`".$db_prefix." tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '0为不显示，1为默认为显示',
  PRIMARY KEY (`".$db_prefix."fid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=12 DEFAULT CHARSET=utf8 COMMENT='友情链接'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."goods`");
$db->exe("CREATE TABLE `".$db_prefix."goods`".$db_prefix." (
  `".$db_prefix."goods_id`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."goods_sn`".$db_prefix." varchar(30) NOT NULL DEFAULT '',
  `".$db_prefix."goods_name`".$db_prefix." varchar(100) NOT NULL DEFAULT '',
  `".$db_prefix."goods_brief`".$db_prefix." varchar(255) NOT NULL DEFAULT '',
  `".$db_prefix."market_price`".$db_prefix." decimal(10,2) NOT NULL DEFAULT '0.00',
  `".$db_prefix."shop_price`".$db_prefix." decimal(10,2) NOT NULL DEFAULT '0.00',
  `".$db_prefix."promote_price`".$db_prefix." decimal(10,2) NOT NULL DEFAULT '0.00',
  `".$db_prefix."promote_start_time`".$db_prefix." int(10) NOT NULL DEFAULT '0',
  `".$db_prefix."promote_end_time`".$db_prefix." int(10) NOT NULL DEFAULT '0',
  `".$db_prefix."goods_img`".$db_prefix." varchar(50) NOT NULL,
  `".$db_prefix."goods_thumb`".$db_prefix." varchar(50) NOT NULL DEFAULT '',
  `".$db_prefix."goods_number`".$db_prefix." smallint(5) NOT NULL DEFAULT '0',
  `".$db_prefix."click`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."is_promote`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."is_hot`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."is_new`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."is_best`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."is_onsale`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '1',
  `".$db_prefix."is_delete`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."add_time`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."type_id`".$db_prefix." smallint(5) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."cat_id`".$db_prefix." smallint(5) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."brand_id`".$db_prefix." smallint(5) DEFAULT '0',
  PRIMARY KEY (`".$db_prefix."goods_id`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=177 DEFAULT CHARSET=utf8");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."goods_attr`");
$db->exe("CREATE TABLE `".$db_prefix."goods_attr`".$db_prefix." (
  `".$db_prefix."goods_att_id`".$db_prefix." int(11) NOT NULL AUTO_INCREMENT,
  `".$db_prefix."attr_value`".$db_prefix." char(15) NOT NULL DEFAULT '' COMMENT '商品属性值',
  `".$db_prefix."attr_price`".$db_prefix." decimal(10,0) NOT NULL DEFAULT '0' COMMENT '附加价格',
  `".$db_prefix."gid`".$db_prefix." int(10) unsigned NOT NULL COMMENT '商品属性表和商品表的关联id',
  `".$db_prefix."attr_id`".$db_prefix." int(10) NOT NULL,
  PRIMARY KEY (`".$db_prefix."goods_att_id`".$db_prefix."),
  KEY `".$db_prefix."fk_goods_attr_goods1_idx`".$db_prefix." (`".$db_prefix."gid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=723 DEFAULT CHARSET=utf8 COMMENT='商品属性表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."goods_list`");
$db->exe("CREATE TABLE `".$db_prefix."goods_list`".$db_prefix." (
  `".$db_prefix."gtid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."combine`".$db_prefix." char(50) NOT NULL DEFAULT '' COMMENT '组合属性ID',
  `".$db_prefix."number`".$db_prefix." char(30) NOT NULL DEFAULT '' COMMENT '货品货号',
  `".$db_prefix."inventory`".$db_prefix." smallint(6) unsigned NOT NULL DEFAULT '0' COMMENT '库存量',
  `".$db_prefix."gid`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '所属商品ID',
  PRIMARY KEY (`".$db_prefix."gtid`".$db_prefix."),
  KEY `".$db_prefix."fk_ccshop_goods_list_ccshop_goods1_idx`".$db_prefix." (`".$db_prefix."gid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=68 DEFAULT CHARSET=utf8 COMMENT='货品列表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."goods_type`");
$db->exe("CREATE TABLE `".$db_prefix."goods_type`".$db_prefix." (
  `".$db_prefix."type_id`".$db_prefix." smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."type_name`".$db_prefix." varchar(50) NOT NULL DEFAULT '',
  `".$db_prefix."sort`".$db_prefix." smallint(6) DEFAULT NULL,
  PRIMARY KEY (`".$db_prefix."type_id`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."user`");
$db->exe("CREATE TABLE `".$db_prefix."user`".$db_prefix." (
  `".$db_prefix."uid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."username`".$db_prefix." char(50) NOT NULL DEFAULT '',
  `".$db_prefix."pwd`".$db_prefix." char(32) NOT NULL DEFAULT '',
  `".$db_prefix."tel`".$db_prefix." char(11) NOT NULL,
  `".$db_prefix."reg_time`".$db_prefix." int(11) DEFAULT NULL,
  PRIMARY KEY (`".$db_prefix."uid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=103 DEFAULT CHARSET=utf8");
